<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>用户列表页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/tpblog/public/static/admin/css/font.css">
    <link rel="stylesheet" href="/tpblog/public/static/admin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/tpblog/public/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/tpblog/public/static/admin/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body class="layui-anim layui-anim-up">
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">用户管理</a>
        <a>
          <cite>用户列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <table class="layui-table">
        <thead>
          <tr>
            <th>ID</th>
            <th>姓名</th>
            <th>年龄</th>
            <th>性别</th>
            <th>地址</th>
            <th>电话</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
        {foreach users as $us}
          <tr>
            <td>{$us.id}</td>
            <td>{$us.uname}</td>
            <td>{$us.age}</td>
            <td>{$us.sex}</td>
            <td>{$us.address}</td>
            <td>{$us.tel}</td>
            <td class="td-manage">
              <a title="编辑" href="{:url('admin/user/edit',['id'=>$us.id])}">
                <i class="layui-icon">&#xe642;</i>
              </a>
              <a title="删除" class="user-del" dataid="{$us.id}" href="#">
                <i class="layui-icon">&#xe640;</i>
              </a>
            </td>
          </tr>
        {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div>
          <a class="prev" href="">&lt;&lt;</a>
          <a class="num" href="">1</a>
          <a class="num" href="">3</a>
          <a class="num" href="">489</a>
          <a class="next" href="">&gt;&gt;</a>
        </div>
      </div>

    </div>
    <script>
        $(function () {
          $(".user-del").click(function () {
              var id=$(this).attr('dataid');
              layer.confirm('确认删除吗？',{
                title:'删除用户',
                icon:3
              },function (index) {
                  layer.close(index);
                  $.ajax({
                    url:"{:url('admin/user/del')}",
                    type:"post",
                    data:{id:id},
                    dataType:'json',
                    success:function (data) {
                      if(data.code==1){
                        layer.msg(data.msg,{
                          icon:6,
                          time:2000
                        },function () {
                          location.href=data.url;
                        })
                      }else{
                        layer.open({
                          title:'删除失败',
                          content:data.msg,
                          icon:5,
                          anim:6
                        })
                      }
                    }
                  })
              });
              return false;
          });
        })
     </script>
  </body>

</html>